Skip to content

Conversation

@kornelski
Copy link
Collaborator

@kornelski kornelski commented Jun 13, 2025

We tell bindgen to generate newtypes for enums:

.default_enum_style(bindgen::EnumVariation::NewType {

but Boring uses an anonymous enum for ERR_LIB_* constants:

https://github.com/google/boringssl/blob/5622da92e1e7bacb5d0785ff5650a5a23b143b84/include/openssl/err.h#L223-L224

so bindgen picks _bindgen_ty_1. I wanted to use the newtypes in an API, but referring to the type as _bindgen_ty_1 is fragile, because it could break if boringssl adds any other anonymous type, or bindgen finds one in system headers.

There's a bit of hacky parsing to find the actual type name of ERR_LIB_SSL's newtype (bindgen doesn't expose AST or anything like that). The newtype is pub used under a future-proof ErrLib name.

@kornelski kornelski merged commit 78b8cea into master Sep 26, 2025
25 checks passed
@kornelski kornelski deleted the err-lib-newtype branch September 26, 2025 13:17
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants